<?php

require_once 'cms/forum/om/om/BaseTopic.php';


/**
 * Skeleton subclass for representing a row from the 'topic' table.
 *
 * 
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package cms.forum.om
 */	
class Topic extends BaseTopic {

    private $count;
    private $latest;

    public function getCount() {
        return $this->count;
    }

    public function setCount($count) {
        $this->count = $count;
    }

    public function hydrate(ResultSet $rs, $startcol = 1)
    {
        $startcol = parent::hydrate($rs, $startcol);

        try {
            $this->count = $rs->getInt($startcol);
        } catch(Exception $e) {
            ;
        }
    }

    public function getLatestReply() {

        if($this->latest === null) {

            require_once("cms/forum/om/TopicReplyPeer.php");

            $c = new Criteria();
            $c->add(TopicPeer::ACTIVE, true);
            $c->add(TopicReplyPeer::TOPIC_ID, $this->getTopicId());
            $c->add(TopicReplyPeer::ACTIVE, true);

            $c->addJoin(TopicReplyPeer::TOPIC_ID, TopicPeer::TOPIC_ID);
            $c->addDescendingOrderByColumn(TopicReplyPeer::INSERT_DATE);
            $c->setLimit(1);

            $this->latest = TopicReplyPeer::doSelectOne($c);

        }

        return $this->latest;

    }

} // Topic
